package com.leadbank.baselbf.outils;

import android.content.Context;
import android.os.Environment;

import com.leadbank.baselbf.base.BaseApplication;

import java.io.File;

/**
 * @ClassName: APPSysTools
 * @Description: 系統相关类，例：
 *  文件
 *
 * @Author: zhouzhiguo
 * @Date: 2023/11/27 18:00
 * @Version: 5.0.6
 * 上海利得金融科技集团版权所有.
 */

public class APPSysTools {
    /**
     * 获得内部缓存文件
     * @return
     * @author yangli
     */
    public static String getSysDirCache(Context context){
        String cachePath = "";
        if ((Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())
                || !Environment.isExternalStorageRemovable())
                && context.getExternalCacheDir() != null) {
            cachePath = context.getExternalCacheDir().getPath();
        } else {
            cachePath = context.getCacheDir().getPath();
        }
        return cachePath;
    }

    /**
     * 获得系统保存文件目录
     * @return
     * @author yangli
     */
    public static String getSysDir(){

        File internalStorage = BaseApplication.getBaseApplication().getFilesDir();
        String path = internalStorage.getAbsolutePath();
        return path;
    }

    /**
     * 获得内部文件 Pictures目录
     * @return
     * @author yangli
     */
    public static String getSysDirPicture(){
        File internalStorage = BaseApplication.getBaseApplication().getExternalFilesDir(Environment.DIRECTORY_PICTURES);
        String path = internalStorage.getAbsolutePath();
        return path;
    }

    /**
     * 获得内部文件 DownLoads目录
     * @return
     * @author yangli
     */
    public static String getSysDirDownLoads(){
        File internalStorage = BaseApplication.getBaseApplication().getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS);
        String path = internalStorage.getAbsolutePath();
        return path;
    }

}
